<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

/**
 * HTML View class for the HelloWorld Component
 */
class WebteamViewPortfolio extends JViewLegacy
{
	// Overwriting JView display method
	function display($tpl = null)
	{
		
		$catid = JRequest::getVar("catid");
		//var_dump($catid);
		if($catid == NULL) $catid = 8;
		$db = JFactory::getDbo();
		$sql = "SELECT * FROM #__content WHERE catid = ".$catid;
		$db->setQuery($sql);
		$list = $db->loadObjectList(); 
		
		$items = array(); 
		for($i=0; $i < count($list); $i++){
			
			$items[$i]["id"] = $list[$i]->id;
			$items[$i]["name"] = $list[$i]->title;
			$images = json_decode($list[$i]->images);
			$items[$i]["image"] = $images->image_intro;
			
		}
		//echo "<pre>";print_r($items);exit;
		
		$this->assignRef('items',$items);
		
		parent::display($tpl);
	
	}

}